<template>
  <a-switch v-model="defaultContract" @change="submit" :disabled="Archive == 1" />
</template>
<script>
import { updataDfault, getDetailList } from '@/api/common'
export default {
  name: 'switchContract',
  components: {},
  props: ['record'],
  data() {
    return {
      defaultContract: false,
      pagination: {
        total: 1,
        pageSize: 20
      },
      Archive: 0
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    async getData() {
      this.defaultContract = this.record.defaultContract ? true : false
      const id = this.$route.query.id
      const r = await getDetailList(id)
      this.Archive = r.result.data.Archive
    },
    async submit() {
      const form = {
        defaultContract: this.defaultContract ? 1 : 0
      }
      await updataDfault(this.record.id, form)
      this.$emit('update')
    }
  },
  created() {},
  mounted() {
    this.getData()
  }
}
</script>
<style lang="css" scoped></style>
